from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains

# 指定ChromeDriver的路径
service = Service(executable_path='D:/Program Files/Python/drives/chromedriver.exe')
#service = Service(executable_path='C:\Program Files\Google\Chrome\Application')

# 创建ChromeOptions对象
options = Options()
# 禁用GPU加速
options.add_argument('--disable-gpu')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
# 指定Chrome浏览器的路径
#options.binary_location = 'D:\WorkSoftware\chrome-win64\chrome.exe'
options.binary_location = 'C:/Program Files/Google/Chrome/Application/chrome.exe'

# 创建WebDriver对象
driver = webdriver.Chrome(service=service, options=options)

# 打开百度页面
driver.get('http://127.0.0.1:8090/dist/#/login?flag=1&userId=admin')
time.sleep(5)
driver.set_window_size(1920, 1040)
time.sleep(3)
driver.find_element(By.CSS_SELECTOR, ".menu-item-box:nth-child(5) .iconUrl").click()
time.sleep(1)
driver.find_element(By.CSS_SELECTOR, ".is-active .el-menu-item:nth-child(4)").click()
time.sleep(2)
driver.find_element(By.CSS_SELECTOR, ".el-table__row:nth-child(1) .el-checkbox__inner").click()
time.sleep(1)
driver.find_element(By.CSS_SELECTOR, "#btn-list > .el-button:nth-child(2) > span").click()
driver.find_element(By.CSS_SELECTOR, ".el-form-item:nth-child(4)").click()
time.sleep(1)
driver.find_element(By.CSS_SELECTOR, ".el-form-item:nth-child(4) .el-input__inner").click()
time.sleep(2)
driver.find_element(By.CSS_SELECTOR, ".el-form-item:nth-child(4) .el-input__inner").click()
driver.find_element(By.CSS_SELECTOR, ".el-form-item:nth-child(4) .el-input__inner").send_keys("5678999")
driver.find_element(By.CSS_SELECTOR, "div:nth-child(1) > .el-button--default:nth-child(3) > span").click()
time.sleep(2)
# 关闭浏览器
print("Quitting Chrome...")
driver.quit()
print("Chrome quit successfully.")